package net.zjitc.securityloginapijwt.listener;

import jakarta.annotation.Resource;
import net.zjitc.securityloginapijwt.utils.ConstantUtil;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class ApplicationShutdownListener implements ApplicationListener<ContextClosedEvent> {
    @Resource
    private RedisTemplate<String,Object> redisTemplate;
    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        redisTemplate.delete(ConstantUtil.REDIS_TOKEN_KEY);
    }
}
